#include"Include.h"

void Timer0_Init(void)
{   
	_tmr0c=0b10000100;   		//Timer mode,Fsys/16
	_tmr0=256-125;				// 125us=1us*125  
	_t0f=0;
	_t0e=1;
	_t0on=1;
}

void Timer1_Init(void)
{
	_tmr1c=0b10000101;   		//Timer mode,Fsys/32   
	_tmr1=256-75;				//100us		  
	_t1f=0;
	_t1e=1;
	_mf2f=0;
	_mf2e=1;
}

void Timer2_Init(void)
{
	_tmr2c=0b00000100;   		//Timer mode,Fsys/16   
	_tmr2=256-12;				//12us	=1us*12	 
	_t2on=1;
}
void TimeBase()	//1ms 
{
	static vu8 Timer_10mS;	
	static vu8 Timer_20mS ;
	static vu8 Timer_100mS ;
	static vu8 Timer_1S;
	Timer_10mS++;
	
	if(Timer_10mS>=10)
	{
		Timer_10mS=0;
		bT10mS_Event=1;
		Timer_20mS++;
	}	
	if(Timer_20mS >= 2)
	{
		Timer_20mS=0;
		bT20mS_Event=1;		
		Timer_100mS++;
		if (Timer_100mS>=5) //20mS x 5
		{
			Timer_100mS = 0;
            bT100mS_Event = 1;
            Timer_1S++; // 1 Sec count with 100mS reslolution
		}	
        if (Timer_1S >= 10)
        {
            bT1S_Event = 1;
            Timer_1S = 0;
        }				
	} 
}



